package com.cn.longdistancebusstation.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.cn.longdistancebusstation.R;
import com.cn.longdistancebusstation.base.BaseActivity;
import com.cn.longdistancebusstation.contacter.ContacterListActivity;
import com.cn.longdistancebusstation.view.PaymentOrderListView;

/**
 * Created by Administrator on 2018/1/19.
 */

public class PaymentOrderActivity extends BaseActivity implements View.OnClickListener,AdapterView.OnItemClickListener{
    private PaymentOrderListView mPaymentOrderListView;
    private TextView mSelectPassengerTextView;
    private Button btn_pay,btn_pay_cancle;
    private String bookOrderNo,ticketDate,ticketSeatNo,modiMode;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_payment_order);
        getTitleTextView().setText("订单支付");
        initView();
    }

    private void initView() {
        mSelectPassengerTextView=(TextView)findViewById(R.id.select_passengers);
        btn_pay=(Button)findViewById(R.id.btn_pay);
        btn_pay.setOnClickListener(this);
        btn_pay_cancle=(Button)findViewById(R.id.btn_pay_cancle);
        btn_pay_cancle.setOnClickListener(this);
        mPaymentOrderListView=(PaymentOrderListView)findViewById(R.id.list_passengers_informations);
        mPaymentOrderListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            }
        });


    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.select_passengers:
                select_passengers();
                break;
            case R.id.btn_pay:
                pay();
                break;
            case R.id.btn_pay_cancle:
                pay_cancle();
                break;

        }
        
    }

    private void select_passengers() {
        Intent in=new Intent(PaymentOrderActivity.this,ContacterListActivity.class);
        startActivity(in);
    }
    private void pay(){
        Intent in=new Intent(PaymentOrderActivity.this,PayActivity.class);
        startActivity(in);

    }
    private void pay_cancle(){
//        Retrofit retrofit=new HttpHelper.HttpServiceBuilder().build().getRetrofit();
//        HttpService httpService=retrofit.create(HttpService.class);
//        Call<String> call=httpService.cancelOrder(bookOrderNo,ticketDate,ticketSeatNo);
//        call.enqueue(new Callback<String>() {
//            @Override
//            public void onResponse(Call<String> call, Response<String> response) {
//                Gson gson=new Gson();
//                String data=response.body();
//                JsonObject obj = new JsonParser().parse(data).getAsJsonObject();
//                Boolean isSuccess=obj.get("isSuccess").getAsBoolean();
//                if(isSuccess){
//                    Toast.makeText(PaymentOrderActivity.this,"订单也成功取消",Toast.LENGTH_SHORT).show();
//                }else{
//                    Toast.makeText(PaymentOrderActivity.this,"订单取消失败",Toast.LENGTH_SHORT).show();
//                }
//            }
//
//            @Override
//            public void onFailure(Call<String> call, Throwable t) {
//
//            }
//        });


    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

    }
}
